#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
/**
 * Definition for a binary tree node.
 * struct TreeNode {
 *     int val;
 *     TreeNode *left;
 *     TreeNode *right;
 *     TreeNode() : val(0), left(nullptr), right(nullptr) {}
 *     TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}
 *     TreeNode(int x, TreeNode *left, TreeNode *right) : val(x), left(left),
 * right(right) {}
 * };
 */
class Solution {
public:
    long prev = LONG_MIN;
    bool dfs(TreeNode* root) {
        if (!root)
            return true;
        if (dfs(root->left)) {
            if (root->val > prev) {
                prev = root->val;
                return dfs(root->right);
            }
            else {
                return false;
            }
        }
        else {
            return false;
        }
    }
    bool isValidBST(TreeNode* root) { return dfs(root); }
};
int main(){

	return 0;
}